﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using NS.Utilities;
using NS.BLL.Systems;

public partial class Main : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {     
        if (string.IsNullOrEmpty(CookieHelper.GetValue("uid")))
        {
            form1.Visible = false;
            MessageBox.AppendScript(this, "alert('登陆超时！');this.location.href = 'Login.aspx';");
        }
        else
        {
            labUserName.Text = CookieHelper.GetValue("uname");
            string mode = System.Configuration.ConfigurationManager.AppSettings["Mode"];
             if (mode == "saas")
             {
                 labDept.Text = CompanyService.GetCompanyNameByCompanyID(CookieHelper.GetValue("companyid"));
             }
             else
             {
                 labDept.Text = DeptService.GetDeptNameByDeptID(CookieHelper.GetValue("deptid"));
             }
        }
    }

    //安全退出
    protected void lbtnExit_Click(object sender, EventArgs e)
    {
        CookieHelper.Delete("uid");
        CookieHelper.Delete("umobile");
        CookieHelper.Delete("uname");
        CookieHelper.Delete("companyid");
        CookieHelper.Delete("deptid");
        MessageBox.AppendScript(this, "parent.location.href = 'Login.aspx';");
    }
}